<style>
    .tginput{
        margin-top:10px;
        margin-bottom:10px;
        padding-left:19px;
        background:none repeat scroll 0 0 #FAFAFA;
        border:1px solid #cccccc;
        color:#069CBC;
        font-size:20px;
        line-height:30px;
        height:35px;
        width: 400px;
    }
    .tgbutton{
        margin-top: -10px;
        margin-left: 25px;
        font-size:1.5em;

        height: 39px;
        width:100px;
        cursor:pointer;
        display:-moz-inline-stack;
        line-height: 35px;
        overflow: visible;
        text-decoration: none;
        vertical-align: middle;
    }
</style>
<div class="tableform">
    <form action="index.php?app=wms&ctl=admin_stock&act=search" id="formid" method="post">
        <h3>库存查询</h3>
        <div class="division">
            <table>
                <tr>
                    <td>
                        <div style="position:relative">
                            <input type="text" id="stock_search" name="stock_search" class="tginput" value="<{$keywords}>" />
                            <button type="submit" id="btn_search" class='tgbutton'><span><span>查询</span></span></button>(请录入基础物料编码、条形码或者基础物料名称)
                    </td>
                </tr>
            </table>
        </div>

        <div class="division">
            <table class="gridlist" cellpadding="0" cellspacing="0">
                <thead>
                <tr>
                    <th>基础物料编码</th>
                    <th style='text-align:left;'>基础物料名称</th>
                    <th>基础物料品牌</th>
                    <th>条形码</th>
                    <th>规格</th>
                    <th>仓库名</th>
                    <th>货位</th>
                    <th style="display:none;">数量(最大/实际)</th>
                    <th>实际库存</th>
                    <th>临期库存</th>
                    <th>预警库存</th>
                </tr>
                </thead>
                <{if $data}>
                <tbody>
                <{foreach from=$data item=product}>
                <tr>
                    <td><{$product.bn}></td>
                    <td style='text-align:left;'><{$product.name|visibility:$product.product_id}></td>
                    <td><{$product.brand_name}></td>
                    <td><{$product.barcode}></td>
                    <td><{$product.spec_info|default:'-'}></td>
                    <td><{$product.branch|default:'-'}></td>
                    <td><{$product.store_position|default:'-'}></td>
                    <td style="display:none;"><{$product.max_store|default:0}>/<{$product.store|default:0}></td>
                    <td><{$product.store|default:0}></td>
                    <td style="font-weight:bold;"><{if $product.balance_num}><a class="show_instock_page" bm_id="<{$product.product_id}>" branch_id="<{$product.branch_id}>" style="color:#3367ac"><{$product.balance_num}></a><{else}>-&nbsp;&nbsp;<{/if}></td>
                    <td style="font-weight:bold;"><{if $product.warn_num}><a class="show_instock_warn_page" bm_id="<{$product.product_id}>" branch_id="<{$product.branch_id}>" style="color:#3367ac"><{$product.warn_num}></a><{else}>-&nbsp;&nbsp;<{/if}></td>
                </tr>
                <{/foreach}>
                </tbody>
                <{/if}>
            </table>
        </div>
    </form>
</div>
<script>
    $('stock_search').focus();
    (function(){
        new Autocompleter.script($E('#stock_search'),"index.php?app=ome&ctl=admin_stock&act=getProductsByAuto", {
            'getVar':'stock_search',
            'fxOptions':false,
            callJSON:function(){return window.autocompleter_json;},
            injectChoice:function(json){
                var choice = new Element('li', {'html': this.markQueryValue(json[this.options.getVar])});
                choice.inputValue = json[this.options.getVar];
                this.addChoiceEvents(choice).inject(this.choices);
            }
        });
    })();
    function visibility(e){
        var visiTips = new Tips({
            onShow:function(tip,el){
                el.addClass('active');
                tip.setStyle('display','block');
            },
            text: function(element){
                if(element.get('visibility')=='false'){
                    return '不可售商品';
                }else{
                    return '';
                }
            }
        });

        var e  = new Event(e), el = e.target;
        if (el.get('visibility')=='false')
        {
            visiTips.attach(el);
            el.addEvent('mouseleave',function(){
                el.removeClass('active');
            });
            el.fireEvent('mouseenter',e);
        }
    }

    $$('.show_instock_page').addEvent("click",function()
    {
        var bm_id = this.get('bm_id');
        var branch_id = this.get('branch_id');

        if(bm_id == '' || branch_id == '')
        {
            alert('无效操作');
            return false;
        }
        new Dialog('index.php?app=wms&ctl=admin_stock&act=show_storage_life',{width:700,height:500,title:'关联保质期批次',ajaxoptions:{data:{branch_id:branch_id,bm_id:bm_id},method:'post'}});
    });

    $$('.show_instock_warn_page').addEvent("click",function()
    {
        var bm_id = this.get('bm_id');
        var branch_id = this.get('branch_id');

        if(bm_id == '' || branch_id == '')
        {
            alert('无效操作');
            return false;
        }
        new Dialog('index.php?app=wms&ctl=admin_stock&act=show_warn_storage_life',{width:700,height:500,title:'关联保质期批次',ajaxoptions:{data:{branch_id:branch_id,bm_id:bm_id},method:'post'}});
    });
</script>